import { _decorator, Component, Node } from 'cc';
import { BaseView } from '../base/BaseView';
import { UIManager } from '../../manger/UIManager';

const { ccclass, property } = _decorator;

@ccclass('DefaultCloseViewButton')
export class DefaultCloseViewButton extends Component {
    @property(Node)
    viewNode: Node = null

    getView():BaseView {
        if (this.viewNode) {
            return this.viewNode.getComponent(BaseView as any)
        }
        return UIManager.getViewInParent(this.node)
    }

    onTouch() {
        const view = this.getView()
        if (view) {
            view.onTouchClose()
        }
    }


}


